<?php

namespace Libraries\OAuth2Client;

class OAuth2ClientFactory
{
    public static function createClient($type)
    {

        if ($type == 'alipay') {
            $alipayNew = CONFIG('alipayNew');
            $client = new AlipayOAuth2Client($alipayNew);
        } else if($type == 'wechat'){
            $config = CONFIG('wechat.mp');
            $client = new WechatOAuth2Client(array(
                'clientId' => $config['appId'],
                'clientSecret' => $config['appSecret'],
                'redirectUri' => $config['redirectUri'],
            ));
        } else {
            throw new InvalidArgumentException('un supported type'.$type, 1);
        }

        return $client;
    }
}